<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>League</title>
        <link href="css/global.css" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="js/global.js"></script>

        <!-- jquery DataTable !-->
        <h:outputStylesheet name="../resources/DataTables-1.9.4/media/css/jquery.dataTables.css"/>
        <h:outputScript name="../resources/DataTables-1.9.4/media/js/jquery.js"/>
        <h:outputScript name="../resources/DataTables-1.9.4/media/js/jquery.dataTables.js"/>>
        <script language="javascript">
            $(document).ready(function(){
                $("[class$='dataTable']").dataTable();
                $("div.navy").load("navy.xhtml");
            });
        </script>
        <script>
            function toggleLeagueInfo(tog){
                if(tog=="standingtable"){
                    document.getElementById("standingtable").style.visibility="visible";
                    document.getElementById("scheduletable").style.visibility="hidden";
                }else{
                    document.getElementById("standingtable").style.visibility="hidden";
                    document.getElementById("scheduletable").style.visibility="visible";
                }
            }

            function toggleSchedule(tog){
                if(tog=="scoreboardtable"){
                    document.getElementById("scoreboardtable").style.visibility="visible";
                    document.getElementById("NFLscheduletable").style.visibility="hidden";
                }else{
                    document.getElementById("scoreboardtable").style.visibility="hidden";
                    document.getElementById("NFLscheduletable").style.visibility="visible";
                }
            }
        </script>
    </h:head>
    <h:body>
        <div id="background">
            <div class="navy">

            </div>
            <div id="content">
                <div id="leagueDiv">
                    <h:outputText value="#{accountBean.currentLeague.leagueName}" style="font-size:20px; color:white;"/>
                    <span class="whiteHeader">League Home</span><br/><br/>
                    <div id="leagueInfo">
                        <button class="long" onclick="toggleLeagueInfo('standingtable');"><span class="white">Standing</span></button>
                        <button class="long" onclick="toggleLeagueInfo('scheduletable');"><span class="white">Schedule</span></button>
                        <button class="long"><span class="white">Playoff</span></button><br/>
                        <f:view>
                            <h:form>
                                <h1><h:outputText value="List"/></h1>
                                <h:dataTable class="dataTable" value="#{standing.teams}" var="item">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Team"/>
                                        </f:facet>
                                        <h:outputText value="#{item.name}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Logo"/>
                                        </f:facet>
                                        <h:outputText value="#{item.logoUrl}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Win"/>
                                        </f:facet>
                                        <h:outputText value="#{item.currentWin}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Lose"/>
                                        </f:facet>
                                        <h:outputText value="#{item.currentLose}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Draw"/>
                                        </f:facet>
                                        <h:outputText value="#{item.currentWithdraw}"/>
                                    </h:column>
                                </h:dataTable>
                            </h:form>
                        </f:view>

                        <table id="scheduletable">
                            <tr><td>
                                    <f:view>
                                        <h:form id="fantasyScheduleForm">
                                            <h:commandButton value="Week #{scheduleBean.currentWeek.week-1}" style="#{scheduleBean.currentWeek.week == 1 ? 'visibility:hidden;' : 'cursor:pointer;border:none; background:none;font-size:12px;'}">
                                                <f:ajax render="fantasyScheduleForm" listener="#{scheduleBean.previousWeek()}"/>
                                            </h:commandButton>
                                            <h:outputText value="Week #{scheduleBean.currentWeek.week}"/>
                                            <h:commandButton value="Week #{scheduleBean.currentWeek.week+1}" style="#{scheduleBean.currentWeek.week == 14 ? 'visibility:hidden;' : 'cursor:pointer;border:none; background:none;font-size:12px;'}">
                                                <f:ajax render="fantasyScheduleForm" listener="#{scheduleBean.nextWeek()}"/>
                                            </h:commandButton>
                                            <h:dataTable id="fantasymatchschedule" value="#{scheduleBean.fantasyMathchList}" var="item">
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Score"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.homeScore}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Home Team"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.homeTeamId.name}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Away Team"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.awayTeamId.name}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Score"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.awayScore}"/>
                                                </h:column>
                                            </h:dataTable>
                                        </h:form>
                                    </f:view>
                                </td></tr>
                        </table>
                    </div>
                    <div id="scoreboard">
                        <button class="long" onclick="toggleSchedule('scoreboardtable');"><span class="white">My League</span></button>
                        <table id="scoreboardtable">
                            <tr>
                                <td>
                                    <f:view>
                                        <h:form id="fantasyScheduleForm2">
                                            <h:commandButton value="Week #{scheduleBean.currentWeek.week-1}" style="#{scheduleBean.currentWeek.week == 1 ? 'visibility:hidden;' : 'cursor:pointer;border:none; background:none;font-size:12px;'}">
                                                <f:ajax render="fantasyScheduleForm2" listener="#{scheduleBean.previousWeek()}"/>
                                            </h:commandButton>
                                            <h:outputText value="Week #{scheduleBean.currentWeek.week}"/>
                                            <h:commandButton value="Week #{scheduleBean.currentWeek.week+1}" style="#{scheduleBean.currentWeek.week == 14 ? 'visibility:hidden;' : 'cursor:pointer;border:none; background:none;font-size:12px;'}">
                                                <f:ajax render="fantasyScheduleForm2" listener="#{scheduleBean.nextWeek()}"/>
                                            </h:commandButton>
                                            <h:dataTable id="fantasymatchschedule" value="#{scheduleBean.fantasyMathchList}" var="item">
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Score"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.homeScore}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Home Team"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.homeTeamId.name}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Away Team"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.awayTeamId.name}"/>
                                                </h:column>
                                                <h:column>
                                                    <f:facet name="header">
                                                        <h:outputText value="Score"/>
                                                    </f:facet>
                                                    <h:outputText value="#{item.awayScore}"/>
                                                </h:column>
                                            </h:dataTable>
                                        </h:form>
                                    </f:view>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </h:body>
</html>
